const HtmlWebpackPlugin = require('html-webpack-plugin')

const path = require("path")
const {
    Generator
} = require('webpack')

module.exports = {
    devServer: {
        port: 3009,
        open: true
    },
    mode: "production",
    entry: './src/man.js',
    output: {
        path: path.join(__dirname, './dist'),
        filename: "bundle.js"
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './pubilc/index.html'
        })
    ],
    module: {
        rules: [{
                test: /\.css$/i,
                use: ["style-loader", "css-loader"]
            }, {
                test: /\.less$/i,
                use: ["style-loader", "css-loader", "less-loader"]
            }, {
                test: /\.(png|jpg|gif|jpeg)$/i,
                type: 'asset',
                generator: {
                    filename: "imags/[name][ext]"
                }
            }, {
                test: /\.(eot|svg|ttf|woff|woff2)$/i,
                type: 'asset/resource',
                generator: {
                    filename: "font/[name].[hash:6][ext]"
                },
            },
            {
                test: /\.m?js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env'],
                        plugins: ['@babel/plugin-proposal-object-rest-spread']
                    }
                }
            }

        ]
    },
}